package com.zhongyouyun.admin.model;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;

import java.util.ArrayList;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.zhongyouyun.other.model.TreeModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @Author: shenyi
 * @Date: 2021-12-17
 * @Description:
 */

@ApiModel(value = "DeptModel对象", description = "部门")
@Data
@TableName("z_dept")
@Accessors(chain = true)
public class DeptModel implements Serializable, TreeModel<DeptModel> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @ApiModelProperty(value = "账号")
    @TableField("xiangmu_type")
    private String xiangMuType;

    @ApiModelProperty(value = "机构名称")
    @TableField("dept_name")
    private String deptName;

    @ApiModelProperty(value = "机构编号")
    @TableField("dept_no")
    private String deptNo;

    @ApiModelProperty(value = "上级")
    @TableField("p_id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long pId;


    public void setpId(final Long pId) {
        this.pId = pId;
    }

    @ApiModelProperty(value = "排序")
    @TableField("order_num")
    private Integer orderNum;


    @ApiModelProperty(value = "部门id")
    @TableField("dept_id")
    @JsonSerialize(using = ToStringSerializer.class)
    @JsonInclude
    private Long deptId;

    @ApiModelProperty(value = "是否删除")
    @TableField("is_del")
    private String isDel;


    @ApiModelProperty(value = "创建人")
    @TableField("createBy")
    private String createBy;


    @ApiModelProperty(value = "创建时间")
    @TableField("createTime")
    private Date createTime;


    @ApiModelProperty(value = "1全部，2本部门，3部门及以下，4本人")
    @TableField("data_scope")
    private Integer dataScope;

    @ApiModelProperty(value = "部門ID全路径")
    @TableField("full_path_id")
    private String fullPathId;


    @ApiModelProperty(value = "修改人")
    @TableField("updateBy")
    private String updateBy;


    @ApiModelProperty(value = "修改时间")
    @TableField("updateTime")
    private Date updateTime;

    @ApiModelProperty(value = "备注")
    @TableField("remark")
    private String remark;


    @ApiModelProperty(value = "部门子级")
    @TableField(exist = false)
    private List<DeptModel> routes;

    @ApiModelProperty(value = "父级名称")
    @TableField(exist = false)
    private String parentName;

//    public List<DeptModel> getRoutes() {
//        if (ObjectUtil.isEmpty(this.routes)){
//            this.routes= new ArrayList<DeptModel>();
//        }
//        return this.routes;
//    }


}